package com.bytedance.scenedemo.dialog;

import com.bytedance.scene.dialog.BottomSheetDialogScene;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;
import ohos.agp.utils.TextAlignment;

/**
 * Created by JiangQi on 11/25/18.
 */
public class BottomSheetDialogSample extends BottomSheetDialogScene {
    private static final int CONSTANT_56 = 56;
    private static final int CONSTANT_400 = 400;
    private static final int CONSTANT_2300 = 2300;
    private static final int CONSTANT_133456 = 133456;
    private static final int CONSTANT_0XFF0000FF = 0xFF0000FF;
    private static final int CONSTANT_0XFFFFFF00 = 0xFFFFFF00;

    @Override
    protected Component onCreateContentView(LayoutScatter inflater,
                                            ComponentContainer container, Intent savedInstanceState) {
        DirectionalLayout directionalLayout = new DirectionalLayout(getActivity());
        DirectionalLayout.LayoutConfig layoutConfig = new DirectionalLayout.LayoutConfig();
        layoutConfig.height = DirectionalLayout.LayoutConfig.MATCH_PARENT;
        layoutConfig.width = DirectionalLayout.LayoutConfig.MATCH_PARENT;
        directionalLayout.setOrientation(DirectionalLayout.VERTICAL);
        directionalLayout.setLayoutConfig(layoutConfig);
        directionalLayout.setId(CONSTANT_133456);

        Text text = new Text(getActivity());
        text.setText("Expand Me！");
        text.setTextColor(Color.WHITE);
        text.setTextSize(CONSTANT_56);
        text.setTextAlignment(TextAlignment.VERTICAL_CENTER);
        ShapeElement shapeElement = new ShapeElement();
        shapeElement.setRgbColor(RgbColor.fromArgbInt(CONSTANT_0XFF0000FF));
        text.setBackground(shapeElement);
        text.setClickedListener(component -> {});
        DirectionalLayout.LayoutConfig layoutConfig2 = new DirectionalLayout.LayoutConfig();
        layoutConfig2.width = DirectionalLayout.LayoutConfig.MATCH_PARENT;
        layoutConfig2.height = CONSTANT_400;
        directionalLayout.addComponent(text, layoutConfig2);

        DirectionalLayout.LayoutConfig layoutConfig3 = new DirectionalLayout.LayoutConfig();
        layoutConfig3.width = DirectionalLayout.LayoutConfig.MATCH_PARENT;
        layoutConfig3.height = CONSTANT_2300;
        Component component = new Component(getActivity());
        ShapeElement shapeElement2 = new ShapeElement();
        shapeElement2.setRgbColor(RgbColor.fromArgbInt(CONSTANT_0XFFFFFF00));
        component.setBackground(shapeElement2);
        directionalLayout.addComponent(component, layoutConfig3);
        return directionalLayout;
    }
}
